//    Copyright (C) Kherty.  All rights reserved.
using System;
using OpenLS.Core.Serialization;
using OpenLS.Spreadsheet;

namespace OpenLS.Spreadsheet.Pivot
{
    internal class PageField : IOfficeXmlSerializable
    {
        Int32 _fld;
        UInt32? _item;
        Int32? _hier;
        string _name;
        string _cap;
        ExtensionList _extLst;
        private const string xmlName = "pageField";

        public void ReadXml(ReadContext context)
        {
            using (var c = context.Read(xmlName))
            {
                _fld = c.GetInteger("fld");
                _item = c.GetOptionalUInteger("item");
                _hier = c.GetOptionalInteger("hier");
                _name = c.GetOptionalString("name");
                _cap = c.GetOptionalString("cap");
                _extLst = c.ReadOptionalElement<ExtensionList>("extLst");
            }
        }
        public void WriteXml(WriteContext context)
        {
            using (var c = context.Write(xmlName))
            {
                c.SetInteger("fld", _fld);
                c.SetOptionalUInteger("item", _item);
                c.SetOptionalInteger("hier", _hier);
                c.SetOptionalString("name", _name);
                c.SetOptionalString("cap", _cap);
                c.WriteOptionalElement(_extLst);
            }
        }
    }

}